package Servlet;

import Utils.DbUtil;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/ToAddServlet")
public class ToAddServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=UTF-8");
        String tableName = req.getParameter("tableName");
        System.out.println(tableName);
        List<String> columnNames = DbUtil.getColumnCount(req,tableName);
        System.out.println(columnNames.toString());
        req.setAttribute("columnNames", columnNames);
        req.setAttribute("tableName", tableName);
        RequestDispatcher dispatcher = req.getRequestDispatcher("add.jsp");
        dispatcher.forward(req, resp);
    }
}
